<template>
	<view class="content" v-if="show==1">
		<view class="daohang">
			<view class="daohang2" @click="url2" :data-url="'/pages/teacher/kcadd?cid='+x.id" v-for="(x,index) in xueke">
				<image :src="x.image" mode="aspectFit"/>
				<view class="dh_t">{{x.title}}</view>
			</view>
		</view>
		
		<view class="fenge"></view>
		
		<view class="order" >
			<view class="dao" @click="url" data-url='/pages/teacher/kc'>
				<view class="dao2">已发布服务列表</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
		</view>
		<view style="width:100%;height:110px;"></view>
		<view class="fabu" v-if="user.is_end==0">
			<view class="fabu2" @click="url2" data-url="/pages/teacher/kcadd">发布服务</view>
		</view>
	</view>
</template>

<script>
	var app=getApp();
	export default {
		data() {
			return {
				show:0,
				uid:0,
				xueke:[],
				cate:[],
				user:[]
			}
		},
		onLoad() {
			const uid = uni.getStorageSync('uid');
			if(app.isBlank(uid)==true){
				uni.reLaunch({
				    url: "/pages/index/index"
				});
				return false;
			}
			this.uid=uid;
			this.getdata();
		},
		methods: {
			getdata(){
				var that=this;
				uni.request({
				    url: app.globalData.url+"laoshi/goods_cate",
					method:"POST",
					dataType:"json",
					header: {
					    'content-type': 'application/x-www-form-urlencoded'
					},
				    data: {uid:that.uid},
				    success: (res) => {
						uni.hideLoading();
						if(res.data.code==1){
							that.xueke=res.data.data.xueke
							that.user=res.data.data.user
							that.show=1;
						}else if(res.data.code==4000){
							uni.removeStorageSync('uid');
							uni.reLaunch({
							    url: "/pages/index/index"
							});
						}else if(res.data.code==4100){
							
							uni.reLaunch({
							    url: "/pages/index/index"
							});
						}else{
							uni.reLaunch({
							    url: '/pages/index/index'
							});
							return false;
						}
				    }
				});
			},
			url(e){
				var url=e.currentTarget.dataset.url;
				uni.navigateTo({
				    url: url
				});
			},
			url2(e){
				if(this.user.status==2){
					uni.showToast({
					    title: "您的账户已被封号",
						icon:'none',
					    duration: 1500
					});
					return false;
				}
				if(this.user.status==0){
					uni.showToast({
					    title: "您还没有入驻，不能发布",
						icon:'none',
					    duration: 1500
					});
					return false;
				}
				if(this.user.status==4){
					uni.showToast({
					    title: "您的师傅账户已注销",
						icon:'none',
					    duration: 1500
					});
					return false;
				}
				if(this.user.is_end==1){
					uni.showToast({
					    title: "您的账户已到期",
						icon:'none',
					    duration: 1500
					});
					return false;
				}
				/*if(this.user.is_real==0){
					uni.showToast({
					    title: "您未实名认证，不能发布",
						icon:'none',
					    duration: 1500
					});
					return false;
				}*/
				var url=e.currentTarget.dataset.url;
				uni.navigateTo({
				    url: url
				});
			}
		}
	}
</script>

<style>
	.fabu2{width:94%;margin: 0 auto;height:40px;line-height: 40px;text-align: center;color: #fff;text-align: center;background-color: #05c160;border-radius: 5px;margin-top: 5px;}
	.fabu{width:100%;height:50px;background-color: #fff;position: fixed;bottom: 0px;z-index: 9990;}
	
	.daohang{width:100%;overflow: hidden;margin-top: 5px;margin-bottom: 15px;}
	.daohang2{width:20%;float: left;text-align: center;margin-top: 10px;display: block;}
	.daohang2 image{width:35px;height:35px;}
	.dh_t{width:96%;padding: 0px 2%;height:20px;line-height: 20px;text-align: center;font-size: 0.8rem;overflow: hidden;}

	.dao2 text{color:red;font-size: 0.7rem;margin-left: 5px;}
	.order .dao:last-child{margin-bottom: 10px;}
	.tubiao2{width:20px;height:20px;margin-top: 7.5px;}
	.dao2{width:100%;height:40px;line-height: 40px;flex:1;font-size: 0.9rem;}
	.tubiao{width:30px;height:30px;margin-top: 5px;margin-right: 8px;border-radius: 50%;}
	.dao{width:94%;padding: 3px 3%;display: flex;height:40px;border-bottom:1px rgb(245, 245, 245) solid;}
	.user5-3{width:100%;height:20px;line-height: 20px;text-align: center;}
	.user5-2{width:100%;height:30px;line-height: 30px;text-align: center;overflow: hidden;font-size: 0.95rem;}
	.user5-1{width:100%;height:20px;line-height: 20px;text-align: center;font-size: 0.8rem;}
	.user3-3{width:100%;height:20px;line-height: 20px;text-align: center;}
	.user3-2{width:100%;height:30px;line-height: 30px;text-align: center;overflow: hidden;font-size: 0.95rem;}
	.user3-1{width:100%;height:20px;line-height: 20px;text-align: center;font-size: 0.8rem;}
	.user4-1{width:1px;height:70px;background-color: rgb(245, 245, 245);margin: 0 auto;}
	.user5{width:49.5%;height:70px;float: left;}
	.user4{width:1%;height:70px;float: left;text-align: center;}
	.user3{width:49.5%;height:70px;float: left;}
	.user2{width:96%;padding: 10px 2%;overflow: hidden;}
	.fenge{width:100%;height:6px;background-color: rgb(245, 245, 245);}
	.header{width:100%;height:100px;background-color:#05c160;position: relative;}
	.header_1{width:100%;height:100px;overflow: hidden;}
	.avatar{width:25%;float: left;text-align: center;height:100px;}
	.avatar image{width:70px;margin-top: 15px;border-radius: 50%;height:70px;}
	.nickname{width:70%;float: left;height:100px;overflow: hidden;}
	.nick{width:100%;height:30px;line-height: 30px;margin-top: 13px;font-size: 1rem;color:#fff;overflow: hidden;}
	.nick2{width:70%;height:100px;line-height: 100px;font-size: 1.1rem;color:#fff;overflow: hidden;float: left;}
	.nick3{width:25%;height:33px;border:1px #fff solid;border-radius: 5px;text-align: center;line-height: 33px;color:#fff;float: right;margin-top: 32.5px;}
	.level{width:100%;height:20px;line-height: 20px;color:#fff;font-size: 0.7rem;}
	.site{width:15%;float: left;height:100px;text-align: center;}
	.site image{width:25px;margin-top: 15px;}
	.bai{width:100%;height:50px;background-color: #fff;opacity: 0.15;position: absolute;bottom: 0px;}
	
	.order{width:100%;}
	.order_1{width:96%;padding: 0px 2%;overflow: hidden;border-bottom: 1px rgb(245, 245, 245) solid;}
	.order_1_1{width:50%;height:40px;line-height: 40px;font-size: 1rem;float: left;color:#333;font-weight: 600;}
	.order_1_2{width:50%;height:40px;float: left;overflow: hidden;}
	.order_1_2 image{width:16px;margin-top:12px;float: right;}
	.order_1_2 text{line-height: 40px;float: right;color:#999;}
	.tui_goods{width:96%;padding-left: 2%;padding-right: 2%;overflow: hidden;margin-top: 15px;}
	.tui_goods_1{width:50%;float: left;margin-bottom: 10px;}
	.tui_goods_1_1{width:98%;}
	.tui_goods_1_1 image{width:100%;border-radius: 5px;}
	.tui_title{width:100%;height:25px;line-height: 25px;color:#666;overflow:hidden;text-overflow: ellipsis;white-space: nowrap; }
	.tui_price{width:100%;height:25px;line-height: 25px;color:#f36;}
	.tui_goods_1:nth-of-type(even) .tui_goods_1_1{float: right;}
	.tui_price text{font-size: 0.7rem;color:#999;float: right;}
	
</style>
